home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 1.iso / dist / patchSG0003743.idb / usr / include / fortran.h.z / fortran.h
C/C++ Source or Header  |  2001-04-12  |  22KB  |  724 lines

  1. /* USMID @(#) clibinc/fortran.h    92.4    05/17/99 10:11:13 */
  2.  
  3. /*
  4. *
  5. * Copyright 1997, Silicon Graphics, Inc.
  6. * All Rights Reserved.
  7. *
  8. * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  9. * the contents of this file may not be disclosed to third parties, copied or
  10. * duplicated in any form, in whole or in part, without the prior written
  11. * permission of Silicon Graphics, Inc.
  12. *
  13. * RESTRICTED RIGHTS LEGEND:
  14. * Use, duplication or disclosure by the Government is subject to restrictions
  15. * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  16. * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  17. * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  18. * rights reserved under the Copyright Laws of the United States.
  19. */
  20.  
  21. /*
  22.  *    (C) COPYRIGHT CRAY RESEARCH, INC.
  23.  *    UNPUBLISHED PROPRIETARY INFORMATION.
  24.  *    ALL RIGHTS RESERVED.
  25.  */
  26.  
  27. #ifndef _FORTRAN_H
  28. #define _FORTRAN_H
  29.  
  30.  
  31. /*
  32.  * C declarations for Fortran data types and for interlanguage data and
  33.  * descriptor conversions.
  34.  *
  35.  * This header file defines a C type for each of the supported Fortran-90
  36.  * types and kinds.   Descriptor conversion macros are defined to map
  37.  * between C character pointers and the FORTRAN Character Descriptor format.
  38.  * Data conversion macros are available for converting between Fortran
  39.  * LOGICAL and C boolean (integer).
  40.  */
  41.  
  42. /*
  43.  * Fortran data types:   
  44.  *
  45.  * The mappings listed below match a Fortran data type with a corresponding
  46.  * C data type.   The related data types agree in:
  47.  *
  48.  *    1) Memory packing size.
  49.  *    2) Range of values which can be operated on or stored.
  50.  *
  51.  * Each data type has a macro of the form _F_INT4 which is defined only
  52.  * on platforms which support the data type.  In cases where there is a
  53.  * set of data types which all have the same memory packing size, and the
  54.  * same range of values, only the one with the largest declared kind is
  55.  * defined.
  56.  */
  57.  
  58. #if    defined(_CRAY1)
  59.  
  60. /*
  61.  * The non-declaration of _F_INT4 is an exception to our rule of defining
  62.  * the macros for data types.  While int kind=4 is defined for YMP, the
  63.  * compiler does not treat it differently from int kind=6, and does not
  64.  * create any new entry points for it.  Therefore, it was decided not to
  65.  * define _F_INT4.  The declared value for these macros is dependent upon
  66.  * whether the data type is really supported, or whether the type is defined
  67.  * as an array of another type, or is a single entity.  Those which are
  68.  * a single entity are defined as 1, which those which are defined as array
  69.  * are defined to be (-1).
  70.  *
  71.  * 6/13/95 - typedef statements are being added for non-supported data
  72.  *         types for use in the array intrinsics.  These data types are
  73.  *         valid for PVP, but they are treated by the compiler as instances
  74.  *         of the next larger distinct type.  (i.e. _f_int4 is valid, but
  75.  *         is treated as an _f_int6).  These new entry points are being
  76.  *         added for the MAXVAL/MINVAL routines, which can have distinct
  77.  *         entry points for each valid data type.
  78.  */
  79.  
  80. #define    _F_INT6        1
  81. #define    _F_INT8        1
  82.  
  83. typedef    int        _f_int6;    /* integer kind=6 (46-bit on CX/CEA) */
  84. typedef    long        _f_int8;    /* integer kind=8 */
  85. typedef    _f_int6        _f_int;        /* integer of default kind */
  86. typedef    _f_int8        _f_int4;    /* integer kind=4 */
  87. typedef    _f_int8        _f_int2;    /* integer kind=2 */
  88. typedef    _f_int8        _f_int1;    /* integer kind=1 */
  89.  
  90. #define    _F_LOG8        1
  91.  
  92. typedef    long        _f_log8;    /* logical kind=8 */
  93. typedef    _f_log8        _f_log;        /* logical of default kind */
  94. typedef    _f_log8        _f_log4;    /* logical kind=4 */
  95. typedef    _f_log8        _f_log2;    /* logical kind=2 */
  96. typedef    _f_log8        _f_log1;    /* logical kind=1 */
  97.  
  98. #define    _F_REAL8    1
  99. #define    _F_REAL16    1
  100.  
  101. typedef    double        _f_real8;    /* real kind=8 */
  102. typedef    long double    _f_real16;    /* real kind=16 */
  103.  
  104. typedef    _f_real8    _f_real;    /* real of default kind */
  105. typedef    _f_real16    _f_dble;    /* double precision */
  106. typedef    _f_real8    _f_real4;    /* real kind=4 */
  107.  
  108. #define    _F_COMP8    1
  109. #define    _F_COMP16    1
  110.  
  111. #if !defined(__cplusplus)
  112. #include <complex.h>
  113. typedef    _Complex double    _f_comp8;    /* complex kind=8 */
  114. /* typedef _Complex long double    _f_comp16; */    /* complex kind=16 */
  115. typedef    _f_comp8    _f_comp;    /* complex of default kind */
  116. #endif
  117.  
  118. #endif    /* defined(_CRAY1) */
  119.  
  120.  
  121. #if    defined(_CRAYMPP)
  122.  
  123. /*
  124.  * 6/13/95 - typedef statements are being added for non-supported data
  125.  *         types for use in the array intrinsics.  These data types are
  126.  *         valid for PVP, but they are treated by the compiler as instances
  127.  *         of the next larger distinct type.  (i.e. _f_int2 is valid, but
  128.  *         is treated as an _f_int4).  These new entry points are being
  129.  *         added for the MAXVAL/MINVAL routines, which can have distinct
  130.  *         entry points for each valid data type.  */
  131.  
  132. #define    _F_INT4        1
  133. #define    _F_INT8        1
  134.  
  135. typedef    short        _f_int4;    /* integer kind=4 */
  136. typedef    int        _f_int8;    /* integer kind=8 */
  137. typedef    _f_int8        _f_int;        /* integer of default kind */
  138. typedef    _f_int4        _f_int2;    /* integer kind=2 */
  139. typedef _f_int4        _f_int1;    /* integer kind=1 */
  140.  
  141. #define    _F_LOG4        1
  142. #define    _F_LOG8        1
  143.  
  144. typedef    short        _f_log4;    /* logical kind=4 */
  145. typedef    long        _f_log8;    /* logical kind=8 */
  146. typedef    _f_log8        _f_log;        /* logical of default kind */
  147. typedef    _f_log4        _f_log2;    /* logical kind=2 */
  148. typedef    _f_log4        _f_log1;    /* logical kind=1 */
  149.  
  150. #define    _F_REAL4    1
  151. #define    _F_REAL8    1
  152.  
  153. typedef float        _f_real4;    /* real kind=4 */
  154. typedef    double        _f_real8;    /* real kind=8 */
  155. #if _LD64
  156. typedef    struct {long x[2];} _f_real16;    /* real kind=16 */
  157. #define    _F_REAL16    (-1)
  158. #else
  159. typedef    long double    _f_real16;    /* real kind=16 */
  160. #define    _F_REAL16    1
  161. #endif
  162. typedef    _f_real8    _f_real;    /* real of default kind */
  163. typedef    _f_real16    _f_dble;    /* double precision */
  164. typedef _f_real4    _f_real2;    /* real kind=2 */
  165.  
  166. #define _F_COMP4    1
  167. #define    _F_COMP8    1
  168.  
  169. #if !defined(__cplusplus)
  170. #include <complex.h>
  171. typedef _Complex float    _f_comp4;    /* complex kind=4 */
  172. typedef    _Complex double    _f_comp8;    /* complex kind=8 */
  173. /* typedef _Complex long double    _f_comp16; */    /* complex kind=16 */
  174. typedef    _f_comp8    _f_comp;    /* complex of default kind */
  175. #endif
  176.  
  177. #endif    /* _CRAYMPP */
  178.  
  179.  
  180. #if    defined(__mips)
  181.  
  182. /*
  183.  *    MIPS n32 and 64 ABIs.
  184.  */
  185.  
  186. #define    _F_INT1        1
  187. #define    _F_INT2        1
  188. #define    _F_INT4        1
  189. #define    _F_INT8        1
  190.  
  191. typedef signed char    _f_int1;     /* integer kind=1 */
  192. typedef    short        _f_int2;    /* integer kind=2 */
  193. typedef    int        _f_int4;    /* integer kind=4 */
  194. typedef    long long    _f_int8;    /* integer kind=8 */
  195. typedef    _f_int4        _f_int;        /* integer of default kind */
  196.  
  197. #define    _F_LOG1        1
  198. #define    _F_LOG2        1
  199. #define    _F_LOG4        1
  200. #define    _F_LOG8        1
  201.  
  202. typedef    signed char    _f_log1;    /* logical kind=1 */
  203. typedef    short        _f_log2;    /* logical kind=2 */
  204. typedef    int        _f_log4;    /* logical kind=4 */
  205. typedef    long long    _f_log8;    /* logical kind=8 */
  206. typedef    _f_log4        _f_log;        /* logical of default kind */
  207.  
  208. #define    _F_REAL4    1
  209. #define    _F_REAL8    1
  210. #define    _F_REAL16    1
  211.  
  212. typedef    float        _f_real4;    /* real kind=4 */
  213. typedef    double        _f_real8;    /* real kind=8 */
  214. typedef    long double    _f_real16;    /* real kind=16 */
  215. typedef    _f_real4    _f_real;    /* real of default kind */
  216. typedef    _f_real8    _f_dble;    /* double precision */
  217.  
  218. #define    _F_COMP4    (-1)
  219. #define    _F_COMP8    (-1)
  220. #define    _F_COMP16    (-1)
  221.  
  222. typedef struct {_f_real4 x[2];} _f_comp4;  /* complex kind=4 */
  223. typedef struct {_f_real8 x[2];} _f_comp8;  /* complex kind=8 */
  224. typedef struct {_f_real16 x[2];} _f_comp16;  /* complex kind=16 */
  225. typedef    _f_comp4    _f_comp;    /* complex of default kind */
  226.  
  227. #endif    /* __mips */
  228.  
  229. #if    defined(_LITTLE_ENDIAN)
  230. /*
  231.  *    32- and 64-bit ABIs.
  232.  */
  233.  
  234. #define    _F_INT1        1
  235. #define    _F_INT2        1
  236. #define    _F_INT4        1
  237. #define    _F_INT8        1
  238.  
  239. typedef signed char    _f_int1;     /* integer kind=1 */
  240. typedef    short        _f_int2;    /* integer kind=2 */
  241. typedef    int        _f_int4;    /* integer kind=4 */
  242. typedef    long         _f_int8;    /* integer kind=8 */
  243. typedef    _f_int4        _f_int;        /* integer of default kind */
  244.  
  245. #define    _F_LOG1        1
  246. #define    _F_LOG2        1
  247. #define    _F_LOG4        1
  248. #define    _F_LOG8        1
  249.  
  250. typedef    signed char    _f_log1;    /* logical kind=1 */
  251. typedef    short        _f_log2;    /* logical kind=2 */
  252. typedef    int        _f_log4;    /* logical kind=4 */
  253. typedef    long        _f_log8;    /* logical kind=8 */
  254. typedef    _f_log4        _f_log;        /* logical of default kind */
  255.  
  256. #define    _F_REAL4    1
  257. #define    _F_REAL8    1
  258. #define    _F_REAL16    1
  259.  
  260. typedef    float        _f_real4;    /* real kind=4 */
  261. typedef    double        _f_real8;    /* real kind=8 */
  262. typedef    long double    _f_real16;    /* real kind=16 */
  263. typedef    _f_real4    _f_real;    /* real of default kind */
  264. typedef    _f_real8    _f_dble;    /* double precision */
  265.  
  266. /* For cray sv2 with a specific complex data type */
  267. #ifdef _CRAY
  268. #define    _F_COMP4    1
  269. #define    _F_COMP8    1
  270. #define    _F_COMP16    1
  271.  
  272. #if !defined(__cplusplus)
  273. #include <complex.h>
  274. typedef    _Complex float    _f_comp4;    /* complex kind=8 */
  275. typedef    _Complex double    _f_comp8;    /* complex kind=8 */
  276. typedef _Complex long double    _f_comp16;     /* complex kind=16 */
  277. typedef    _f_comp8    _f_comp;    /* complex of default kind */
  278. #endif
  279.  
  280. #else    /* _CRAY */
  281. #define    _F_COMP4    (-1)
  282. #define    _F_COMP8    (-1)
  283. #define    _F_COMP16    (-1)
  284.  
  285. typedef struct {_f_real4 x[2];} _f_comp4;  /* complex kind=4 */
  286. typedef struct {_f_real8 x[2];} _f_comp8;  /* complex kind=8 */
  287. typedef struct {_f_real16 x[2];} _f_comp16;  /* complex kind=16 */
  288. typedef    _f_comp4    _f_comp;    /* complex of default kind */
  289. #endif    /* _CRAY */
  290.  
  291. #endif    /* _LITTLE_ENDIAN */
  292.  
  293. #if    !defined(__mips) && defined(_WORD32) && !defined(_LITTLE_ENDIAN)
  294.  
  295. /*
  296.  * 6/13/95 - typedef statements are being added for non-supported data
  297.  *         types for use in the array intrinsics.  These data types are
  298.  *         valid for PVP, but they are treated by the compiler as instances
  299.  *         of the next larger distinct type.  (i.e. _f_int1 is valid, but
  300.  *         is treated as an _f_int2).  These new entry points are being
  301.  *         added for the MAXVAL/MINVAL routines, which can have distinct
  302.  *         entry points for each valid data type.
  303.  */
  304.  
  305. #define    _F_INT2        1
  306. #define    _F_INT4        1
  307. #define    _F_INT8        1
  308.  
  309. typedef    int        _f_int2;    /* integer kind=2 */
  310. typedef    int        _f_int4;    /* integer kind=4 */
  311. typedef    long long    _f_int8;    /* integer kind=8 */
  312. typedef    _f_int4        _f_int;        /* integer of default kind */
  313. typedef _f_int2        _f_int1;    /* integer kind=1 */
  314.  
  315. #define    _F_LOG2        1
  316. #define    _F_LOG4        1
  317. #define    _F_LOG8        1
  318.  
  319. typedef    int        _f_log2;    /* logical kind=2 */
  320. typedef    int        _f_log4;    /* logical kind=4 */
  321. typedef    long long    _f_log8;    /* logical kind=8 */
  322. typedef    _f_log4        _f_log;        /* logical of default kind */
  323. typedef    _f_log2        _f_log1;    /* logical kind=1 */
  324.  
  325. #define    _F_REAL4    1
  326. #define    _F_REAL8    1
  327. #if defined(_SOLARIS)    /* only Solaris is 128-bit for now */
  328. #define    _F_REAL16    1
  329. #endif
  330.  
  331. typedef    float        _f_real4;    /* real kind=4 */
  332. typedef    double        _f_real8;    /* real kind=8 */
  333. typedef    long double    _f_real16;    /* real kind=16 */
  334. typedef    _f_real4    _f_real;    /* real of default kind */
  335. typedef    _f_real8    _f_dble;    /* double precision */
  336.  
  337. #define    _F_COMP4    (-1)
  338. #define    _F_COMP8    (-1)
  339. #define    _F_COMP16    (-1)
  340.  
  341. typedef struct {_f_real4 x[2];} _f_comp4;  /* complex kind=4 */
  342. typedef struct {_f_real8 x[2];} _f_comp8;  /* complex kind=8 */
  343. typedef struct {_f_real16 x[2];} _f_comp16;  /* complex kind=16 */
  344. typedef    _f_comp4    _f_comp;    /* complex of default kind */
  345.  
  346. #endif    /* NOT __mips, _WORD32, _LITTLE_ENDIAN */
  347.  
  348.  
  349. /* Conversion between Fortran character descriptors and C character pointers */
  350.  
  351. /*
  352.  * The "_fcd" type defines a Fortran character variable of default kind.
  353.  * The use of this type is intended for interlanguage communication
  354.  * between C and FORTRAN.  The type _fcd must not be used for any other 
  355.  * purposes.  
  356.  * 
  357.  * The format of Fortran character descriptors on 24-bit A-register systems:
  358.  * 
  359.  *     | 17 bits          | 17 bits       |6 bits|       24 bits       |
  360.  *     -----------------------------------------------------------------
  361.  *     |                  | length        | BO   |     word address    |
  362.  *     -----------------------------------------------------------------
  363.  * 
  364.  * The format of Fortran character descriptors on 32-bit A-register systems:
  365.  * 
  366.  *     |6 bits|         26 bits         |         32 bits              | 
  367.  *     -----------------------------------------------------------------
  368.  *     | BO   |         length          |       word address           |
  369.  *     -----------------------------------------------------------------
  370.  *
  371.  * The format of Fortran character descriptors on 64-bit A-register systems
  372.  * is defined as a two-word structure.  Note that in this instance, there
  373.  * is no need to be concerned about the format of a C character pointer.
  374.  * 
  375.  *     |                             64 bits                           | 
  376.  *     -----------------------------------------------------------------
  377.  *     |                      C Character Pointer                      |
  378.  *     -----------------------------------------------------------------
  379.  *     |   Length (in bits on PVP and T3D; bytes on IRIX/Solaris/T3E )  |
  380.  *     -----------------------------------------------------------------
  381.  * 
  382.  * 
  383.  * The format of C character pointers on 24-bit A-register systems:
  384.  * 
  385.  *     |6 bits|         34 bits                 |       24 bits        | 
  386.  *     -----------------------------------------------------------------
  387.  *     | BO   |                                 |     word address     |
  388.  *     -----------------------------------------------------------------
  389.  * 
  390.  * The format of C character pointers on 32-bit A-register systems:
  391.  * 
  392.  *     |6 bits|         26 bits         |         32 bits              | 
  393.  *     -----------------------------------------------------------------
  394.  *     | BO   |                         |       word address           |
  395.  *     -----------------------------------------------------------------
  396.  * 
  397.  * where BO = bit offset.
  398.  *
  399.  * 
  400.  * _fcdtocp() converts a Fortran character descriptor to a C character 
  401.  * pointer.
  402.  *
  403.  * _fcdlen() extracts the length (in bytes) of a Fortran character
  404.  * descriptor.
  405.  *
  406.  * _isfcd() returns true if an object (of type long) is an _fcd.  This
  407.  * is NOT available on _ADDR64 systems and its use is being deprecated.
  408.  *
  409.  * _cptofcd() converts a C character pointer and a length into a Fortran 
  410.  * character descriptor.
  411.  *
  412.  * The functions _fcdlen and _fcdtocp are guaranteed to work if their 
  413.  * parameters have type _fcd.
  414.  *
  415.  * A Fortran character descriptor converted to a C charactor pointer and back
  416.  * to a Fortran character descriptor:
  417.  *
  418.  *    f = _cptofcd(_fcdtocp(f), _fcdlen(f))
  419.  * 
  420.  * _lvtob() converts a Fortran LOGICAL value to a zero or a one.  The
  421.  * parameter must be of type _f_log.
  422.  *
  423.  * _ltob() converts a Fortran LOGICAL value to a zero or a one.  The
  424.  * parameter must be a pointer.
  425.  *
  426.  * _btol() converts a zero or nonzero value to a Fortran LOGICAL value.
  427.  * The parameter must have integral type.
  428.  *
  429.  * _dvel_len() extracts the element length (in bytes) of an array from
  430.  * a Fortran dope vector.
  431.  *
  432.  * All these functions have both function implementations (so that the address
  433.  * of it can be taken) and macro or inline implementations (for speed).
  434.  */ 
  435. /*
  436.  * The C 6.0 (and later) compiler on Unicos and Unicos/MK systems 
  437.  * recognizes a struct, class, or union with the name "_FCD" as a
  438.  * Fortran character descriptor.
  439.  * It allows an object of this type to be passed to a Fortran function
  440.  * by value instead of taking its address.  (Normally, an object with
  441.  * non-pointer type will have its address taken before being passed to
  442.  * Fortran function.)  Typedefs can be used to rename the type, but the
  443.  * but the underlying struct, class, or union must have the name 
  444.  * "_FCD". The C 4.0 and 5.0 compilers recognize a struct with
  445.  * the name "_FCD" on Cray-T90 and Cray-MPP machines.
  446.  */
  447. #if    !defined(_UNICOS)        /* IRIX, Solaris */
  448.  
  449. typedef    struct    _FCD    {
  450.     char        *c_pointer;    /* C character pointer        */
  451.     unsigned long    byte_len;    /* Length of item (in bytes)    */
  452. } _fcd;
  453.  
  454. typedef    _fcd    _dcf;            /* Equal on this architecture    */
  455.  
  456. /* Define a temporary function to map _dcf's to _fcd's */
  457.  
  458. #define    _fcdtodcf(f)    (f)
  459. #define    _dcftofcd(f)    (f)
  460.  
  461.  
  462. #elif    defined(_ADDR64)         /* CRAY T3D, CRAY TS, Solaris */
  463.  
  464. typedef    struct    _FCD    {
  465.     char        *c_pointer;    /* C character pointer    */
  466.     unsigned long    fcd_len;    /* Length of item    */
  467. } _fcd;
  468.  
  469. typedef    _fcd    _dcf;            /* Equal on this architecture    */
  470.  
  471. /* Define a temporary function to map _dcf's to _fcd's */
  472.  
  473. #define    _fcdtodcf(f)    (f)
  474. #define    _dcftofcd(f)    (f)
  475.  
  476.  
  477. #elif    _ADDR32 && ! defined(_WORD32)    /* CRAY Y-MP and CRAY-2 */
  478.  
  479. typedef    union    _FCD    {
  480.     char    *c_pointer;        /* C character pointer        */
  481.  
  482.     struct    {
  483.     unsigned bit_offset    :  6,    /* Starting bit offset        */
  484.          fcd_len    : 26,    /* Length of item (in bits)    */
  485.          word_addr    : 32;    /* Word address            */
  486.     } _F;
  487. } _dcf;        /* This can be _fcd when compiler knows about _FCD    */
  488.  
  489. typedef    void    *_fcd;    /* Temporary, to ensure fortran functions work    */
  490.  
  491. /* Define a temporary function to map _dcf's to _fcd's */
  492.  
  493. #define    _dcftofcd(f)    (*(_fcd *) &f)
  494. #define    _fcdtodcf(f)    (*(_dcf *) &f)
  495.  
  496.  
  497. #elif    _ADDR32 == 0            /* CRAY X-MP */
  498.  
  499. typedef    union    _FCD    {
  500.  
  501.     struct    {
  502.     unsigned bit_offset    :  6,    /* Starting bit offset        */
  503.          _Unused    : 34,    /* Unused            */
  504.          word_addr    : 24;    /* Word address            */
  505.     } _C;
  506.  
  507.     struct    {
  508.     unsigned _Unused    : 17,    /* Unused            */
  509.          fcd_len    : 17,    /* Length of item (in bits)    */
  510.          bit_offset    :  6,    /* Starting bit offset        */
  511.          word_addr    : 24;    /* Word address            */
  512.     } _F;
  513. } _dcf;    /* This can be _fcd when compiler knows about _FCD */
  514.  
  515. typedef    void    *_fcd;    /* Temporary, to ensure fortran functions work    */
  516.  
  517. /* Define a temporary function to map _dcf's to _fcd's */
  518.  
  519. #define    _dcftofcd(f)    (*(_fcd *) &f)
  520. #define    _fcdtodcf(f)    (*(_dcf *) &f)
  521.  
  522. #endif    /* CRAY X-MP */
  523.  
  524. #include <sys/cdefs.h>
  525.  
  526. __BEGIN_DECLS
  527. extern    _fcd        _cptofcd (char *_Ccp, unsigned _Len);
  528. extern    char *        _fcdtocp (_fcd _Fcd);
  529. extern    unsigned long    _fcdlen (_fcd _Fcd);
  530. extern    _f_log        _btol (long _BV);
  531. extern    long        _lvtob (_f_log _LV);
  532. extern    long        _ltob (_f_log *_LP);
  533. #ifdef    _UNICOS
  534. extern    char *        _f2ccpy (_fcd f, ...);
  535. #endif
  536. extern    char *        _fc_copy (_fcd f, char *s, int slen);
  537. extern    char *        _fc_acopy (_fcd f);
  538. extern  int        _c2fcpy(char *c, _fcd f);
  539.  
  540. #if    defined(_UNICOS) && !defined(_ADDR64) && !defined(_WORD32) 
  541. extern    int        _isfcd (long _P);
  542. #endif
  543.  
  544. #ifdef    _CRAYMPP
  545. extern    void        *_S2PC (void *_SDP, unsigned int _ELSZ);
  546. #endif
  547.  
  548. extern    unsigned long    _dvel_len (long _DVEL);
  549.  
  550. __END_DECLS
  551.  
  552. #if    !defined(_UNICOS)        /* IRIX, Solaris */
  553.  
  554. static    _fcd
  555. __cptofcd(char *c, unsigned long l);
  556. static    _fcd
  557. __cptofcd(char *c, unsigned long l)
  558. {
  559.     _dcf    f;
  560.  
  561.     f.c_pointer    = c;
  562.     f.byte_len    = l;
  563.  
  564.     return (_dcftofcd(f));
  565. }
  566.  
  567. #define    __fcdtocp(f)    ((_fcdtodcf(f)).c_pointer)
  568.  
  569. #define    __fcdlen(f)    ((unsigned long) (_fcdtodcf(f)).byte_len)
  570.  
  571.  
  572. #elif    defined(_ADDR64)         /* CRAY T3D, CRAY TS */
  573.  
  574. static    _fcd
  575. __cptofcd(char *c, unsigned long l);
  576. static    _fcd
  577. __cptofcd(char *c, unsigned long l)
  578. {
  579.     _dcf    f;
  580.  
  581.     f.c_pointer    = c;
  582. #ifdef    _CRAYT3E
  583.     f.fcd_len    = l;
  584. #else
  585.     f.fcd_len    = l << 3;
  586. #endif
  587.  
  588.     return (_dcftofcd(f));
  589. }
  590.  
  591. #define    __fcdtocp(f)    ((_fcdtodcf(f)).c_pointer)
  592.  
  593. #ifdef    _CRAYT3E
  594. #define    __fcdlen(f)    ((unsigned long) (_fcdtodcf(f)).fcd_len)
  595. #else
  596. #define    __fcdlen(f)    ((unsigned long) ((_fcdtodcf(f)).fcd_len) >> 3)
  597. #endif
  598.  
  599.  
  600. #elif    _ADDR32                /* CRAY Y-MP and CRAY-2 */
  601.  
  602. static    _fcd
  603. __cptofcd(char *c, unsigned long l);
  604. #pragma _CRI inline __cptofcd
  605. static    _fcd
  606. __cptofcd(char *c, unsigned long l)
  607. {
  608.     _dcf    f;
  609.  
  610.     f.c_pointer    = c;
  611.     f._F.fcd_len       = l << 3;
  612.  
  613.     return (_dcftofcd(f));
  614. }
  615.  
  616. static    char *
  617. __fcdtocp(_fcd f);
  618. #pragma _CRI inline __fcdtocp
  619. static    char *
  620. __fcdtocp(_fcd f)
  621. {
  622.     char    *c;
  623.     _dcf    d;
  624.  
  625.     d        = _fcdtodcf(f);
  626.     d._F.fcd_len    = 0;
  627.     c        = d.c_pointer;
  628.  
  629.     return (c);
  630. }
  631.  
  632. #define    __fcdlen(f)    ((unsigned int) ((_fcdtodcf(f))._F.fcd_len) >> 3)
  633.  
  634. #define    __isfcd(f)    (__fcdlen(f) != 0)
  635.  
  636. #elif    _ADDR32 == 0            /* CRAY X-MP */
  637.  
  638. static    _fcd
  639. __cptofcd(char *c, unsigned long l);
  640. #pragma _CRI inline __cptofcd
  641. static    _fcd
  642. __cptofcd(char *c, unsigned long l)
  643. {
  644.     _dcf    d;
  645.  
  646.     d        = *(_dcf *) &c;
  647.     d._F.bit_offset    = d._C.bit_offset;
  648.     d._F._Unused    = 0;
  649.     d._F.fcd_len    = l << 3;
  650.  
  651.     return (_dcftofcd(d));
  652. }
  653.  
  654. static    char *
  655. __fcdtocp(_fcd f);
  656. #pragma _CRI inline __fcdtocp
  657. static    char *
  658. __fcdtocp(_fcd f)
  659. {
  660.     char    *c;
  661.     _dcf    d;
  662.  
  663.     d        = _fcdtodcf(f);
  664.     d._C.bit_offset    = d._F.bit_offset;
  665.     d._C._Unused    = 0;
  666.     c        = *(char **) &d;
  667.  
  668.     return (c);
  669. }
  670.  
  671. #define    __fcdlen(f)    ((unsigned long) ((_fcdtodcf(f))._F.fcd_len) >> 3)
  672.  
  673. #define    __isfcd(f)    (__fcdlen(f) != 0)
  674.  
  675. #endif    /* CRAY X-MP */
  676.  
  677. /* Conversion functions between Fortran LOGICAL data and C boolean data */
  678.  
  679. #if    defined(__mips) || defined(_CRAYIEEE) || defined(_SOLARIS) || \
  680.     defined(_SUNOS)  || defined(_ABSOFT) || defined(_LITTLE_ENDIAN)
  681.  
  682. #define __lvtob(l)    ((long)((l) == 0 ? 0 : 1))
  683. #define __btol(b)    ((_f_log)((b) == 0 ? 0 : 1))
  684.  
  685. #elif    defined(_CRAY1)
  686.  
  687. #define __lvtob(l)    ((long)((l) >> 63))
  688. #define __btol(b)    ((_f_log)((b) == 0 ? 0 : -1))
  689.  
  690. #endif /* __mips, _CRAYIEEE, _SOLARIS, _SUNOS, _ABSOFT, _LITTLE_ENDIAN */
  691.  
  692. #define __devl_len(dvl)    ((long)((dvl) >> 3))
  693.  
  694. /* Equivalence inline functions to user-level functions */
  695.  
  696. #define    _cptofcd(_C, _L)    __cptofcd(_C, _L)
  697. #define    _fcdtocp(_F)        __fcdtocp(_F)
  698. #define    _fcdlen(_F)        __fcdlen(_F)
  699. #define    _btol(_BV)        __btol(_BV)
  700. #define _lvtob(_LV)        __lvtob(_LV)
  701. #define _ltob(_LP)        __lvtob(*(_f_log *)_LP)
  702. #define __dvel_len(_DVEL)    __dvel_len(long _DVEL)
  703.  
  704. #if    !defined(_ADDR64) && !defined(_WORD32) && !defined(__mips) && \
  705.     !defined(_LITTLE_ENDIAN)
  706. #define    _isfcd(_U)        __isfcd(_U)
  707. #endif /* NOT _ADDR64,_WORD32, __mips, and _LITTLE_ENDIAN */
  708.  
  709. /*
  710.  *    Determine whether a pointer points to a shared data descriptor.
  711.  *    Note that a shared data descriptor presupposes the centrifuge
  712.  *    function which presupposes CRAFT; which is available only on
  713.  *    the CRAY-T3D.
  714.  */
  715.  
  716. #ifdef    _CRAYT3D
  717. #define    _issddptr(_P)        ((unsigned)(_P) >> 63)
  718. #else
  719. #define    _issddptr(_P)        0
  720. #define    _S2PC(_PTR, _SIZE)    ((void *)(_PTR))
  721. #endif
  722.  
  723. #endif /* !_FORTRAN_H */
  724.